import { Injectable } from '@nestjs/common';
import { CreateAuthorityDto } from './dto/create-authority.dto';
import { UpdateAuthorityDto } from './dto/update-authority.dto';
import { Authority } from './entities/authority.entity';
import { Role } from '../role/entities/role.entity';
import { Repository } from 'typeorm';

import { InjectRepository } from '@nestjs/typeorm';

@Injectable()
export class AuthorityService {
  constructor(
    @InjectRepository(Role)
    private readonly roleRepository: Repository<Role>,
    @InjectRepository(Authority)
    private readonly authorityRepository: Repository<Authority>,
  ) {}

  create(createAuthorityDto: CreateAuthorityDto) {
    return 'This action adds a new authority';
  }

  async findAll() {
    const qb = await this.authorityRepository.find();
    return qb;
  }

  findOne(id: number) {
    return `This action returns a #${id} authority`;
  }

  update(id: number, updateAuthorityDto: UpdateAuthorityDto) {
    return `This action updates a #${id} authority`;
  }

  remove(id: number) {
    return `This action removes a #${id} authority`;
  }
}
